package game;

import java.util.ArrayList;
/*
 * Team: Sting Arrays
 * Creators: Devin La Fleur. and Jonathan Satchell.
 * Game: Defend Chernobly
 */
public class Player {

	public int money;
	public Gun gun;
	public ArrayList<Gun> guns = new ArrayList<Gun>();
	public int health;
	public int totalMoney;

	public static enum Armor
	{
		Straw,Sticks,Bricks,Cement,Vibranium
	}

	public Player()
	{
		money = 0;
		gun = new Gun(Gun.Type.Berretta);//default first gun
		addGun(gun);
		health = 0;
		totalMoney = 0;
	}
	public void addGun(Gun nGun)
	{
		for(Gun aGun : guns)
		{
			if(aGun.equals(nGun))
			{
				return;
			}
		}
		guns.add(nGun);
	}
	public Gun getGun(int z)
	{
		return guns.get(z);
	}

	//sets equipped gun
	public void setGun(Gun nGun)
	{
		gun = nGun;
	}

	//changes the health of the player both from fortifications and enemy damage
	public void changeHealth(int change)
	{
		health += change;
	}
	public int getHealth()
	{
		return health;
	}
	//adds health based on the armor that was selected
	public void addArmor(Armor armor)
	{
		switch(armor)
		{
			case Straw:
				changeHealth(50);
				break;
			case Sticks:
				changeHealth(75);
				break;
			case Bricks:
				changeHealth(100);
				break;
			case Cement:
				changeHealth(150);
				break;
			case Vibranium:
				changeHealth(300);
				break;
		}
	}
	//used to change the amount of money the player has, both buying things and earning from loot
	public void getPaid(int loot)
	{
		money +=loot;
		if(loot>0)
			totalMoney+=loot;
	}
	//returns cost of the armors
	public int getCostArmor(String armor)
	{
		if(armor.equalsIgnoreCase("Sti"))
		{
			return 75;
		}
		else if(armor.equalsIgnoreCase("Str"))
		{
			return 50;
		}
		else if(armor.equalsIgnoreCase("Bri"))
		{
			return 100;
		}
		else if(armor.equalsIgnoreCase("Cem"))
		{
			return 150;
		}
		else if(armor.equalsIgnoreCase("Vib"))
		{
			return 300;
		}
		else
			return 0;
	}
}
